home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
misc
/
amag
/
sh9301c.lha
/
Oberon(S.67)
/
Listing12.mod
< prev
next >
Wrap
Text File
|
1993-01-22
|
3KB
|
105 lines
MODULE Init;
IMPORT
io;
CONST
Blau = 0;
Gruen = 1;
Violett = 2;
(* ... *)
TYPE
Feld = RECORD
name: ARRAY 50 OF CHAR;
spieler: SET;
END;
FeldPtr = POINTER TO Feld;
Kaeuflich = RECORD (Feld)
preis: INTEGER;
hypothek: BOOLEAN;
gekauft: BOOLEAN;
END;
KaeuflichPtr = POINTER TO Kaeuflich;
Tarife = ARRAY 6 OF INTEGER;
Strasse = RECORD (Kaeuflich)
farbe: INTEGER;
haeuser: INTEGER;
miete: Tarife;
END;
StrassePtr = POINTER TO Strasse;
Bahnhof = RECORD (Kaeuflich)
END;
BahnhofPtr = POINTER TO Bahnhof;
(* ... weitere Typen ... *)
VAR
Plan: ARRAY 40 OF FeldPtr;
PROCEDURE Kaufen (VAR KaufFeld: FeldPtr);
BEGIN
IF KaufFeld IS Kaeuflich THEN (* Typtest !!! *)
WITH KaufFeld: Kaeuflich DO
IF KaufFeld.gekauft THEN
io.WriteString (KaufFeld.name);
io.WriteString (" ist schon verkauft!\n");
ELSE
KaufFeld.gekauft := TRUE;
(* ... *)
END;
END;
ELSE
io.WriteString (KaufFeld.name);
io.WriteString (" kann nicht gekauft werden!\n");
END;
END Kaufen;
PROCEDURE InitFeld (Name: ARRAY OF CHAR): FeldPtr;
VAR
NeuesFeld: FeldPtr;
BEGIN
NEW (NeuesFeld); (* Speicher holen *)
IF NeuesFeld = NIL THEN HALT (20) END; (* kein Speicher! *)
COPY (Name, NeuesFeld.name);
NeuesFeld.spieler := SET {};
RETURN NeuesFeld;
END InitFeld;
PROCEDURE InitStrasse (Name: ARRAY OF CHAR;
Preis: INTEGER;
Farbe: INTEGER;
Miete: Tarife): StrassePtr;
VAR
NeueStrasse: StrassePtr;
BEGIN
NEW (NeueStrasse); (* Speicher holen *)
IF NeueStrasse = NIL THEN HALT (20) END; (* kein Speicher! *)
COPY (Name, NeueStrasse.name);
NeueStrasse.spieler := SET {};
NeueStrasse.preis := Preis;
NeueStrasse.hypothek := FALSE;
NeueStrasse.gekauft := FALSE;
NeueStrasse.farbe := Farbe;
NeueStrasse.haeuser := 0;
NeueStrasse.miete := Miete;
RETURN NeueStrasse;
END InitStrasse;
PROCEDURE InitBahnhof (Name: ARRAY OF CHAR;
Preis: INTEGER): BahnhofPtr;
VAR
NeuerBahnhof: BahnhofPtr;
BEGIN
NEW (NeuerBahnhof); (* Speicher holen *)
IF NeuerBahnhof = NIL THEN HALT (20) END; (* kein Speicher! *)
COPY (Name, NeuerBahnhof.name);
NeuerBahnhof.spieler := SET {};
NeuerBahnhof.preis := Preis;
NeuerBahnhof.hypothek := FALSE;
NeuerBahnhof.gekauft := FALSE;
RETURN NeuerBahnhof;
END InitBahnhof;
(* ... *)
BEGIN
Plan[0] := InitFeld ("Start");
Plan[1] := InitStrasse ("Oberonweg", 333, Blau,
Tarife (10, 50, 100, 150, 200, 500));
(* ... *)
Plan[5] := InitBahnhof ("Hauptbahnhof", 500);
(* ... *)
Kaufen (Plan[0]); Kaufen (Plan[1]); Kaufen (Plan[1]);
END Init.